var CONSTS = require('../util/consts');
var moment = require('moment');
var async = require('async');
var Common = require('../util/common');
var CONFIG = require('../config/config').Config;
var nodemailer = require('nodemailer');
var thenjs = require('thenjs');
var crypto = require("crypto");
var validator = require('validator');
var models = require('../models');
var fs = require('fs-extra');

function createAdmin() {
  var avatar = Common.randomAvatar();
  var pwd = '123456';

  models.User.update({
    name: 'admin'
  }, {
    "$set": {
      group: 'admin',
      name: 'admin',
      pwd: models.User.hashPwd(pwd),
      created: moment().utc().format()
    }
  }, {
    upsert: true
  }, function (err, numberAffected, raw) {
    if (err) {
      console.log(err);
      return;
    }

    console.log('create sewing admin user successfully');
  });
}

createAdmin();